import 'package:flutter_demo/models/menu_item.dart';
import 'package:flutter_demo/pages/common/common_appbar.dart';
import 'package:flutter_demo/widgets/select_widget.dart';
import 'package:flutter/material.dart';

/// @author longzipeng
/// @创建时间：2022/3/30
/// 下拉选择demo
class SelectDemoPage extends StatefulWidget {
  const SelectDemoPage({Key? key}) : super(key: key);

  @override
  State<SelectDemoPage> createState() => _SelectDemoPageState();
}

class _SelectDemoPageState extends State<SelectDemoPage> {
  String value = "1";

  /// 下拉选择值改变
  selectChange(value) {
    print("值改变了：$value");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CommonAppbar(
        title: "下拉菜单演示",
      ),
      body: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          SelectWidget(
            items: [
              MenuItem(label: "张飞", value: '1'),
              MenuItem(label: "关羽", value: '2'),
              MenuItem(label: "刘备", value: '3'),
              MenuItem(label: "圆头儿子", value: '4'),
              MenuItem(label: "大头爸爸", value: '5'),
              MenuItem(label: "小头妈妈", value: '6'),
            ],
            value: value,
            valueChanged: selectChange,
          ),
        ],
      ),
    );
  }
}
